<%

Function rodada_deletar_rodada(id)

		
		str = "SELECT id from rodadas where id="&id&" and status=0"
  		Set rs = conexao_geral.Execute(str)	
		
		if not rs.eof then 
				
				str = "SELECT posicao from rodadas_jogos where id_rodada="&id&" order by posicao desc"
  				Set rs2 = conexao_geral.Execute(str)
				
				Do while not rs2.eof
				
					rodada_deletar_jogo id, rs2("posicao")
				
					rs2.MoveNext
				Loop				
				
				str = "DELETE from rodadas where id="&id&" and status=0"
  				Set rs = conexao_geral.Execute(str)	
				
				str = "SELECT id from rodadas where id>"&id&" and status=0 order by id asc"
  				Set rs = conexao_geral.Execute(str)	
				
				DO while not rs.eof
				
								rodada_alterar_rodada_id rs("id")-1, rs("id")
				
					rs.MoveNext
				Loop	
				
				rodada_deletar_rodada = 1
		else
				rodada_deletar_rodada = -1
		End IF
	

End Function
%>
